<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Session checker
 * Just redirect to login when no session created
 *
 * @package		libs
 * @since		Version 1.0
 * @filesource
 */
class Session_checker
{

	function __construct()
	{		
		$CI = &get_instance();
		$this->RTR =& load_class('Router');
		$this->output = $CI->output;
		$this->session = $CI->session;
		
		
		$dir = 	$this->RTR->fetch_directory();
		$class  = $this->RTR->fetch_class();
		$method = $this->RTR->fetch_method();		
		$path = $dir."$class/$method";
						
		$exclude_path = array("main/index","main/login","rpc/index",
		                      "import/rekap_absen_exec","import/test",
		                      "penagihan/main/buatjadwalmassal",
							  "utilities/import/index","utilities/import",
							  "manajemen/lapsales/write_summary",
							  "main/testemail"
							  );
		$exclude = array("rpc/","rpc/index","rpcs/index","rcps/");		
		if(!in_array($dir,$exclude))
		{
			if(!in_array($path,$exclude_path))
			{
				if(!($this->session->userdata('username'))){					
					redirect('main', NULL);			
				}
			}
		}
	}
}